package com.charity.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.charity.domain.Project;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProjectMapper extends BaseMapper<Project> {
    /**
     * 查询项目列表
     * @param status 项目状态（可选）
     * @param offset 偏移量
     * @param pageSize 每页数量
     * @return 项目列表
     */
    @Select({"<script>",
            "SELECT * FROM charity_project ",
            "<where>",
            "<if test='status != null'>",
            "AND status = #{status}",
            "</if>",
            "</where>",
            "ORDER BY create_time DESC ",
            "LIMIT #{offset}, #{pageSize}",
            "</script>"})
    List<Project> selectList(@Param("status") Integer status,
                           @Param("offset") int offset,
                           @Param("pageSize") int pageSize);
}